(function(jQuery){
    $.commitData = function(data){
        this.defaultInit = function(){
			var properties = JSON.parse(getStorage("properties"));
			var submitDept = properties.submitdept;
			var affairType = properties.affairtype;
			var arrangeDept = properties.arrangedept;
			var affairLoc = properties.affairloc;
//			var a=affairLoc.length;
//			var b =parseInt(a/2);
//			var c = a%2;
//			var k =0;
			$$("affairLoc").innerHTML="";
//			 for(var i=0;i<b;i++){
//				$$("affairLoc").innerHTML +='<div class="ub b-gra  ub-f1 ">\
//				    	<div class="ub-f1  uinn" style="width:50%">\
//							<input type="checkbox" name="che1" class="uhide" value="'+affairLoc[k].codeorder+'">\
//							<div class="ub uc-a1 t-bla">\
//							    <div class="che-icon ub-img4 umw2 umh4"></div>\
//								<div class="uinn">'+affairLoc[k].codevalue+'</div>\
//							</div>\
//				        </div>\
//						<div class="ub-f1  uinn" style="width:50%">\
//							<input type="checkbox" name="che1" class="uhide" value="'+affairLoc[k+1].codeorder+'">\
//							<div class="ub uc-a1 t-bla">\
//							    <div class="che-icon ub-img4 umw2 umh4"></div>\
//								<div class="uinn">'+affairLoc[k+1].codevalue+'</div>\
//							</div>\
//				        </div>\
//				    </div>';
//				k+=2;
//			}
//			k-=2;
//			if(c==1){
//					$$("affairLoc").innerHTML +='<div class="ub b-gra ub-f1 ">\
//				    	<div class="ub-f1  uinn" style="width:50%">\
//							<input type="checkbox" name="che1" class="uhide" value="'+affairLoc[k].codeorder+'">\
//							<div class="ub uc-a1 t-bla">\
//							    <div class="che-icon ub-img3 umw2 umh4"></div>\
//								<div class="uinn">'+affairLoc[k].codevalue+'</div>\
//							</div>\
//				        </div>\
//						<div class="ub-f1  uinn" style="width:50%">\
//				        </div>\
//				        </div>\
//				    </div>';
//			}
			var htmlJson = JSON.parse(getStorage("pageJson"));
			var formJson = JSON.parse(getStorage("formJson"));
			
			var affairLoc = properties.affairloc;
			var affairloc = formJson.affairloc;
			 var str = affairloc.split(",");
                for (var i = 0; i < str.length; i++) {
					for(var j=0;j<affairLoc.length;j++){
						if (affairLoc[j].codeorder == str[i]) {
						   $$("affairLoc").innerHTML +='<div class="ub" style="float:left">\
						    <div class="uinn t-wh umar-a uc-a1" style="background-color:#6695c4" >'+affairLoc[j].codevalue+'</div>\
						   </div>';
                        }
					}
                }
//			$("#affairLoc").html(affairloc);
//            if (affairloc != undefined && affairloc != null) {
//                var str = affairloc.split(",");
//                for (var i = 0; i < str.length; i++) {
//                    $('[name="che1"]:checkbox').each(function(){
//                        if (this.value == str[i]) {
//                            this.checked = true;
//							return;
//                        }
//                    });
//                }
//            }
//			var loglist =formJson.loglist;
//			if(loglist.length>0){
//				$("#ramrt").show();
//				for(var i=0;i<loglist.length;i++){
//					$("#logger").append('<div class="umar-b">\
//				      	  <div class="ub ub-ver t-bla ubb umar-b">\
//						    <div class="  uc-t1">\
//								<div class="ub   t-bla">\
//								    <div class=" ub-f1  uc-l1">\
//										<div class="ub   t-bla">\
//										    <div class=" ub-f1 uinn uc-l1">瀹℃牳閮ㄩ棬</div>\
//										    <div class="ub-f1 uinn c-wh uba">'+loglist[i].operatedept+'</div>\
//										</div>\
//								    </div>\
//								    <div class=" ub-f1 ">\
//								    	<div class="ub  t-bla">\
//										    <div class=" ub-f1 uinn uc-l1">瀹℃牳浜�/div>\
//										    <div class="ub-f1 uinn c-wh uba">'+loglist[i].operator+'</div>\
//										</div>\
//								    </div>\
//								    <div class="ub-f1 uinn t-red">涓嶉�杩�/div>\
//								</div>\
//						    </div>\
//					       <div class="uba c-wh b-gra uinput uinn3 umar-t" >\
//			                <textarea placeholder="浜嬩欢鎻忚堪" disabled id="affairRemark" name="textarea-0" class="uc-a1" style="min-height:3em"></textarea>\
//			               </div>\
//					      </div>\
//						 <hr>\
//						</div>');
//				}
//			}else{
//				$("#ramrt").hide();
//			}
			var status =parseInt(formJson.status);
			 $("#imgUp").hide();
			switch(status)
			{
			case 0:
			  $("#0").show();
			  $("#2").hide();
			  $("#1").hide();
			  $("#3").hide();
			  $("#5").hide();
			  break;
			case 2:
			  $("#0").hide();
			  $("#2").show();
			  $("#1").hide();
			  $("#3").hide();
			  $("#5").hide();
			  break;
			  case 3:
			  $("#0").hide();
			  $("#2").hide();
			  $("#1").hide();
			  $("#3").show();
			  $("#5").hide();
			  break;
			  case 5:
			  $("#0").hide();
			  $("#1").hide();
			  $("#2").hide();
			  $("#3").hide();
			  $("#5").show();
			  break;
			default:
			if(status=='1'){
				$("#buttons").show();
			    $("#imgUp").show();
			}else{
				  $("#1").show();
			}
			
			  
			}
			$("#affairRemark").val(formJson.affairremark);
			$("#affairno").val(formJson.affairno);
			for(var i =0;i<arrangeDept.length;i++){
				if(formJson.arrangedept==arrangeDept[i].codeorder){
					$("#arrangeDept").val(arrangeDept[i].codevalue);
				}
			}
			for(var i =0;i<submitDept.length;i++){
				if(formJson.submitdept==submitDept[i].codeorder){
					$("#submitDept").val(submitDept[i].codevalue);
				}
			}
			
			for(var i =0;i<affairType.length;i++){
				if(formJson.affairtype==affairType[i].codeorder){
					$("#affairType").val(affairType[i].codevalue);
				}
			}
			$("#submitMan").val(formJson.submitman);
            $("#carrier").html(formJson.carrier);
            $("#acType").val(formJson.actype);
            $("#acNo").val(formJson.acno);
            $("#flightNo").val(formJson.flightno);
            $("#flightDate").val(getStorage("dateTime"));
            $("#depPort").val(formJson.depairport1);
            $("#depPortName").val(formJson.depairport);
            $("#arrPort").val(formJson.arrairport1);
            $("#arrPortName").val(formJson.arrairport);
            $("#bridge").val(formJson.bridge);
        }
        
        this.init = function(){
            this.acNo = $("#acNo").val();
            this.month = $("#startDate").val();
			this.month = (this.month).substr(0,7);
            this.parma = {
                "acNo": this.acNo = null ? "" : this.acNo,
                "month": this.month = null ? "" : this.month
            };
            $.ajax({
                //鎻愪氦鏁版嵁鐨勭被鍨�POST GET
                type: "POST",
                //鎻愪氦鐨勭綉鍧�
                url: queryUrl+"queryCabinClean",
                //鎻愪氦鐨勬暟鎹�
                data: "parma=" + JSON.stringify(this.parma),
                //杩斿洖鏁版嵁鐨勬牸寮�
                datatype: "json",//"xml", "html", "script", "json", "jsonp", "text".
                //鎴愬姛杩斿洖涔嬪悗璋冪敤鐨勫嚱鏁�            
                success: function(data){
                    json = JSON.parse(data);
                    if (json.status == 0) {
                        $.unsaferanking().append(json.arry);
                    }
                    else {
                       $.iBoxMsg("鎻愪氦澶辫触");
                    }
                },
                //璋冪敤鍑洪敊鎵ц鐨勫嚱鏁�
                error: function(err){ 
                    //璇锋眰鍑洪敊澶勭悊
                    $.iBoxMsg("缃戠粶寮傚父");
                }
            });
        };
        return this;
    }
})(jQuery);
